package com.da.springtest.spring5.reactor;

import java.util.Observable;

/**
 * @author JokerDa.
 * @date 2021/1/6 10:41
 * Description:
 */
public class ObserverDemo extends Observable {
    public static void main(String[] args) {
        ObserverDemo demo = new ObserverDemo();
        // 添加观察者
        demo.addObserver((o, arg) -> System.out.println("发生了变化"));
        demo.addObserver((o, arg) -> System.out.println("被观察者通知，发生改变"));

        demo.setChanged();
        demo.notifyObservers();
    }
}
